<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta http-equiv="Content-Security-Policy" content="default-src * 'self' gap://ready file://* http://* https://* * ; font-src *  data:;img-src data: *; style-src 'self' http://* https://* 'unsafe-inline' blob: ; script-src 'self' http://* https://* 'unsafe-inline' 'unsafe-eval'">
  <meta name="format-detection" content="telephone=no">
  <meta name="msapplication-tap-highlight" content="no">
  <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-touch-fullscreen" content="yes">
  <link rel="stylesheet" type="text/css" href="./static/font/iconfont.css">

  <!-- <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
  <meta http-equiv="Pragma" content="no-cache" />
  <meta http-equiv="Expires" content="0" /> -->

  <title>读书会</title>

</head>

<body>
  <div style="position:absolute;top:40%;left:50%" id="appProLoadingImg">
    <!--<img src="./static/image/loading.gif" style="position:relative;right:50%;width:200px; height:200px;"/>-->
  </div>
  <div id="appFontTester" style="width: 18.75rem;height: 1px"></div>

  <script>
    /**
     * 长投网 授权
     */
    function changTouAuth() {

      var url = location.href.replace(/index\S*$/g, 'wxOauth2.html')
      location.href = url;
    }


    /**
     * 宙乐 授权
     */
    function zhouleAuth() {

      var url = location.href.replace(/index\S*$/g, 'zhouLe.html')
      location.href = url;
    }


    /**
     * 初始化 用户信息
     */
    function initUser() {
      var user = JSON.parse(window.localStorage.getItem('cache-frame-user'));
      if (user) {
        if ((user.phone || user.email)) {
          // 如果用户合法, 将openId替换掉
          var wxAccount = JSON.parse(window.sessionStorage.getItem('wxOauth2'));
          var zhouLeAccount = JSON.parse(window.sessionStorage.getItem('zhouLe'));
          user.openId = wxAccount.openId;
          user.zhouLeId = zhouLeAccount.openId;

          window.localStorage.setItem('cache-frame-user', JSON.stringify(user));
        } else {
          // 如果用户不合法, 踢掉
          window.localStorage.removeItem('cache-frame-user');
        }
      }
    }


    /**
     * 正式环境 授权
     */
    function productAuthorization() {
      if (!window.sessionStorage.getItem('wxOauth2')) {
        // 跳转到 长投网 授权页面
        changTouAuth()
      } else {
        //初始化 用户信息
        init()
      }
      // else if (!window.sessionStorage.getItem('zhouLe')) {
      //   // 跳转到 宙乐 授权页面
      //   zhouleAuth()
      // } else if (window.sessionStorage.getItem('wxOauth2') && window.sessionStorage.getItem('zhouLe')) {
      //   //初始化 用户信息
      //   init()
      // }
    }


    /**
     * 测试环境 授权
     */
    function developAuthorization() {
      if (!window.sessionStorage.getItem('wxOauth2')) {
        // 跳转到 长投 授权页面
        changTouAuth()
      } else {
        //初始化 用户信息
        init()
      }
    }


    /**
     * 设置页面font-size
     */
    function setFontSize() {
      var IPHONE6_SCREEN_WIDTH = 375;
      var DEFAULT_REM = 20;
      var html = document.getElementsByTagName('html')[0];

      // 字体缩放比(1rem = fontScale px)
      window.fontScale = html.offsetWidth / IPHONE6_SCREEN_WIDTH * DEFAULT_REM
      html.style.fontSize = window.fontScale + 'px';

      /**
       * 用户有可能设置了系统字体，此时等比例反缩放
       */
      var appFontTester = document.getElementById('appFontTester')
      var appProLoadingImg = document.getElementById('appProLoadingImg')
      var scale = appFontTester.offsetWidth / html.offsetWidth;

      document.body.removeChild(appFontTester)
      document.body.removeChild(appProLoadingImg)
      if (scale !== 1) {
        html.style.fontSize = parseFloat(window.fontScale) / scale + 'px';
      }
    }


    /**
     * 阻止document页面滚动 (ios系统的webview的滚动)
     */
    // function preventScorller() {
    //   document.addEventListener('touchmove', function(e) {
    //     e.preventDefault();
    //   }, false);
    // }

    /**
     * 缓存当前url上携带的参数
     */
    function cacheParams() {
      window.sessionStorage.removeItem('preAppUrl');

      let url = window.location.href
      let newUrl = url.replace(/\?\S*#!/, '#!')

      var params = newUrl.split('?')[1]
      var paramsArr = params ? params.split('&') : []
      if (paramsArr.length > 0) {
        for (var i = 0, length = paramsArr.length; i < length; i++) {
          var key = paramsArr[i].split('=')[0]
          var value = paramsArr[i].split('=')[1]
          window.localStorage.setItem(key, value)
        }
      }
      window.sessionStorage.setItem('preAppUrl', newUrl);
    }

    /**
     * 启动 app
     */
    function init() {
      //设置字体
      setFontSize()
      //阻止滚动
      // preventScorller()
    }

    (function() {
      cacheParams()

      const ua = navigator.userAgent.toLowerCase();
      const isWx = ua.match(/MicroMessenger/i) && ua.match(/MicroMessenger/i)[0] === "micromessenger";

      if (isWx) {
        //正式环境
        //      productAuthorization()
        //      测试环境
        developAuthorization()
      } else {
        init()
      }

    }())
  </script>
  <!--M站 不需要-->
  <!--<script type="text/javascript" src="cordova.js"></script>-->

  <!-- Dplus  统计 正式环境-->
  <!-- <script type="text/javascript">
    ! function(a, b) {
      if (!b.__SV) {
        var c, d, e, f;
        window.dplus = b, b._i = [], b.init = function(a, c, d) {
          function g(a, b) {
            var c = b.split(".");
            2 == c.length && (a = a[c[0]], b = c[1]), a[b] = function() {
              a.push([b].concat(Array.prototype.slice.call(arguments, 0)))
            }
          }
          var h = b;
          for ("undefined" != typeof d ? h = b[d] = [] : d = "dplus", h.people = h.people || [], h.toString = function(a) {
              var b = "dplus";
              return "dplus" !== d && (b += "." + d), a || (b += " (stub)"), b
            }, h.people.toString = function() {
              return h.toString(1) + ".people (stub)"
            }, e = "disable track track_links track_forms register unregister get_property identify clear set_config get_config get_distinct_id track_pageview register_once track_with_tag time_event people.set people.unset people.delete_user".split(
              " "), f = 0; f < e.length; f++) g(h, e[f]);
          b._i.push([a, c, d])
        }, b.__SV = 1.1, c = a.createElement("script"), c.type = "text/javascript", c.charset = "utf-8", c.async = !0, c.src = "https://w.cnzz.com/dplus.php?token=ea16565d66171ebe26f4", d = a.getElementsByTagName("script")[0], d.parentNode.insertBefore(
          c, d)
      }
    }(document, window.dplus || []), dplus.init("ea16565d66171ebe26f4");
  </script> -->
  <!-- Dplus  统计 测试环境-->
  <!--<script type="text/javascript">!function(a,b){if(!b.__SV){var c,d,e,f;window.dplus=b,b._i=[],b.init=function(a,c,d){function g(a,b){var c=b.split(".");2==c.length&&(a=a[c[0]],b=c[1]),a[b]=function(){a.push([b].concat(Array.prototype.slice.call(arguments,0)))}}var h=b;for("undefined"!=typeof d?h=b[d]=[]:d="dplus",h.people=h.people||[],h.toString=function(a){var b="dplus";return"dplus"!==d&&(b+="."+d),a||(b+=" (stub)"),b},h.people.toString=function(){return h.toString(1)+".people (stub)"},e="disable track track_links track_forms register unregister get_property identify clear set_config get_config get_distinct_id track_pageview register_once track_with_tag time_event people.set people.unset people.delete_user".split(" "),f=0;f<e.length;f++)g(h,e[f]);b._i.push([a,c,d])},b.__SV=1.1,c=a.createElement("script"),c.type="text/javascript",c.charset="utf-8",c.async=!0,c.src="https://w.cnzz.com/dplus.php?token=da168f4458633q92c79b",d=a.getElementsByTagName("script")[0],d.parentNode.insertBefore(c,d)}}(document,window.dplus||[]),dplus.init("da168f4458633q92c79b");</script>-->
  <!-- Dplus  统计-->
  <!-- <script type="text/javascript">
    ! function(a, b) {
      var c, d;
      window.__dplusDefineCacheQueue = [], b.define = function() {
        window.__dplusDefineCacheQueue.push(Array.prototype.slice.call(arguments))
      }, c = a.createElement("script"), c.type = "text/javascript", c.charset = "utf-8", c.async = !0, c.src = "https://w.cnzz.com/dplus.define.php", d = a.getElementsByTagName("script")[0], d.parentNode.insertBefore(c, d)
    }(document, window.dplus);
  </script> -->


  <!--电子书 阅读器-->
  <script src="static/lib/epub.min.js"></script>

  <!--M站 必须 微信js sdk -->
  <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>

  <app></app>
  <!-- built files will be auto injected -->
</body>

</html>
